﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Shohdi.DataHandler;
using DatabaseComponent;

public partial class AccountsEN : System.Web.UI.Page
{



    List<PersonGroups> lstNewPersonGroups
    {
        get
        {
            if (ViewState["lstNewPersonGroups"] == null)
            {
                ViewState["lstNewPersonGroups"] = System.Guid.NewGuid().ToString();
            }


            if (Session[ViewState["lstNewPersonGroups"].ToString()] == null)
            {

                
                Session[ViewState["lstNewPersonGroups"].ToString()] = new List<PersonGroups> ();

            }

            return (List<PersonGroups>)Session[ViewState["lstNewPersonGroups"].ToString()];

        }
        set
        {
            if (ViewState["lstNewPersonGroups"] == null)
            {
                ViewState["lstNewPersonGroups"] = System.Guid.NewGuid().ToString();
            }

            Session[ViewState["lstNewPersonGroups"].ToString()] = value;
        }

    }




    long PersonID
    {
        get
        {
            if (ViewState["PersonID"] == null)
            {
                ViewState["PersonID"] = System.Guid.NewGuid().ToString();
            }


            if (Session[ViewState["PersonID"].ToString()] == null)
            {

                long obj = -1;
                Session[ViewState["PersonID"].ToString()] = obj;

            }

            return (long)Session[ViewState["PersonID"].ToString()];

        }
        set
        {
            if (ViewState["PersonID"] == null)
            {
                ViewState["PersonID"] = System.Guid.NewGuid().ToString();
            }

            Session[ViewState["PersonID"].ToString()] = value;
        }
    }


    Persons objPersons
    {
        get
        {
            if (ViewState["objPersons"] == null)
            {
                ViewState["objPersons"] = System.Guid.NewGuid().ToString();
            }


            if (Session[ViewState["objPersons"].ToString()] == null)
            {
                Session[ViewState["objPersons"].ToString()] = new Persons();

            }

            return (Persons)Session[ViewState["objPersons"].ToString()];

        }
        set
        {
            if (ViewState["objPersons"] == null)
            {
                ViewState["objPersons"] = System.Guid.NewGuid().ToString();
            }


            Session[ViewState["objPersons"].ToString()] = value;
        }
    }



    /// <summary>
    /// this variable will handle the password throw the postbacks
    /// </summary>
    public string strPassword
    {
        get
        {
            if (txtPassword.Text.Trim() != "")
            {
                ViewState["Password"] = txtPassword.Text;
                return ViewState["Password"].ToString();
            }
            else
            {
                if (ViewState["Password"] == null)
                {
                    ViewState["Password"] = "";
                }

                return ViewState["Password"].ToString();
            }
        }

        set
        {
            ViewState["Password"] = value;
        }
    }



    /// <summary>
    /// it will check the security and customize the page
    /// </summary>
    /// <param name="currentPerson">the person to set security to his previleges</param>
    protected void checkSecurityAndCustomizePage(Persons currentPerson)
    {
        //Security Check

        



        if (!currentPerson.lstAllRulesIDs.Contains((long)RulesEnum.Acounts_page))
            Response.Redirect("LoginEN.aspx");



        if (!currentPerson.lstAllRulesIDs.Contains((long)RulesEnum.Editing_Acounts_page))
        {
            btnSave.Enabled = false;
            btnDelete.Enabled = false;
        }



        if (objPersons.GenID != -1)
        {
            if ((from obj in objPersons.lstGroups where obj.GroupNameEN == "Administrator" select obj).ToList().Count > 0)
            {
                if ((from obj in currentPerson.lstGroups where obj.GroupNameEN == "Administrator" select obj).ToList().Count == 0)
                {
                    Response.Redirect("AccountsViewEN.aspx");
                }
            }
        }



    }

    protected void oc1_ItemChanged(object sender, EventArgs e)
    {
        long lOrg = oc1.get();

        if (lOrg <= 0)
        {
            lblOrgCodeBody.Text = "N/A";
            return;
        }


        OrgnizationChartDB objOrgnizationChartDB = new OrgnizationChartDB(ConnectionStrings.LMS);

        List<OrgnizationChart> lstOrgnizationChart = objOrgnizationChartDB.getOrgnizationChartByID(lOrg);

        if (lstOrgnizationChart.Count == 0)
        {
            lblOrgCodeBody.Text = "N/A";
            return;
        }


        lblOrgCodeBody.Text = lstOrgnizationChart[0].OrgCode;

    }





    /// <summary>
    /// this function will check RequestID to detect update or insert
    /// </summary>
    protected void checkID()
    {
        if (Request["ID"] != null)
        {
            try
            {
                PersonID = long.Parse(Request["ID"]);
                PersonsDB objPersonsDB = new PersonsDB(ConnectionStrings.LMS);
                List<Persons> lstPersons = objPersonsDB.getPersonsByGenID(PersonID);
                if (lstPersons.Count > 0)
                {
                    objPersons = lstPersons[0];
                    
                }
                else
                {
                    throw new Exception();

                }


            }
            catch
            {
                Response.Redirect("AccountsViewEN.aspx");
            }
        }
        else
        {
            btnDelete.Visible = false;
           
        }
    }


    /// <summary>
    /// this function for setting Text first time after update or delete
    /// </summary>
    protected void checkMessages()
    {
        if (Request["Err"] != null)
            lblError.Text = Request["Err"];

        if (Request["Msg"] != null)
            lblResult.Text = Request["Msg"];
    }


    /// <summary>
    /// this will bind the user data to update or delete
    /// </summary>
    protected void BindAllControls()
    {
        if (PersonID != -1)
        {
            txtBadge.Text = objPersons.Badge;
            
            txtEmail.Text = objPersons.Email;
            txtFamilyName_AR.Text = objPersons.FamilyName_AR;
            txtFamilyName_EN.Text = objPersons.FamilyName_EN;
            
            txtInnerPhone1.Text = objPersons.InnerPhone1;
            txtInnerPhone2.Text = objPersons.InnerPhone2;
            txtMiddleName_AR.Text = objPersons.MiddleName_AR;
            txtMiddleName_EN.Text = objPersons.MiddleName_EN;
            txtMobile1.Text = objPersons.Mobile1;
            txtMobile2.Text = objPersons.Mobile2;
            txtName_AR.Text = objPersons.Name_AR;
            txtName_EN.Text = objPersons.Name_EN;
            txtPhone1.Text = objPersons.Phone1;
            txtPhone2.Text = objPersons.Phone2;
            strPassword = objPersons.Password;


            ddlEducationLevel.SelectedValue = objPersons.EducationLevel.ToString();
            
            rblGender.SelectedValue = objPersons.Gender.ToString();


            setGroupsValue();
            
            
            if (objPersons.BirthDate != null)
            {
                calBirthDay.set(objPersons.BirthDate.Value);

            }

            ddlNationality.SelectedValue = objPersons.NationalityID.ToString();

            ddlPersonType.SelectedValue = objPersons.PersonTypeID.ToString();


            if (objPersons.PersonTypeID == 3)
            {
                txtID.Text = objPersons.ID;

                ddlRelation.SelectedValue = objPersons.RelationID.ToString();

                pnlEmployee.Visible = false;
                pnlFamily.Visible = true;

            }
            else
            {
                ac1.set(objPersons.OperationAreaID.Value);
                txtChargeAccount.Text = objPersons.ChargeAccount;
                ddlUserType.SelectedValue = objPersons.UserTypeID.ToString();

                oc1.set(objPersons.OrgChartID.Value);

                if (objPersons.objOrgnizationChart.ID <= 0)
                {
                    lblOrgCodeBody.Text = "N/A";
                }
                else
                {
                    lblOrgCodeBody.Text = objPersons.objOrgnizationChart.OrgCode;
                }

                ddlEmploymentStatus.SelectedValue = objPersons.EmploymentStatus.ToString();


                txtPositionEmail.Text = objPersons.PositionEmail;

                txtOfficePhone.Text = objPersons.OfficePhone;
                txtOfficeInnerPhone.Text = objPersons.OfficeInnerPhone;




                pnlEmployee.Visible = true;
                pnlFamily.Visible = false;




            }

            
            

            
        }
    }


    /// <summary>
    /// this function will read all controls values
    /// </summary>
    protected void ReadAllControls()
    {

            objPersons.Badge = txtBadge.Text;

            objPersons.Email = txtEmail.Text;
            objPersons.FamilyName_AR = txtFamilyName_AR.Text;
            objPersons.FamilyName_EN = txtFamilyName_EN.Text;

            objPersons.InnerPhone1 =  txtInnerPhone1.Text;
            objPersons.InnerPhone2=txtInnerPhone2.Text;
            objPersons.MiddleName_AR=txtMiddleName_AR.Text;
            objPersons.MiddleName_EN=txtMiddleName_EN.Text;
            objPersons.Mobile1=txtMobile1.Text;
            objPersons.Mobile2=txtMobile2.Text;
            objPersons.Name_AR=txtName_AR.Text;
            objPersons.Name_EN=txtName_EN.Text;
            objPersons.Phone1=txtPhone1.Text;
            objPersons.Phone2=txtPhone2.Text;

            if (txtPassword.Text.Trim() != "")
            {
                objPersons.Password = LMSSecurity.HashPassword(txtPassword.Text.Trim());
            }

            getGroupsValue();


            objPersons.EducationLevel = long.Parse(ddlEducationLevel.SelectedValue);

            objPersons.Gender = bool.Parse(rblGender.SelectedValue);

           

            objPersons.BirthDate = calBirthDay.get();


           objPersons.NationalityID = long.Parse( ddlNationality.SelectedValue);

           objPersons.PersonTypeID = long.Parse (ddlPersonType.SelectedValue);


            if (objPersons.PersonTypeID == 3)
            {


                objPersons.ID =  txtID.Text  ;

                objPersons.RelationID = long.Parse( ddlRelation.SelectedValue );


                objPersons.UserTypeID = 3;

                


            }
            else
            {
                objPersons.RelationID = 1;


                objPersons.OperationAreaID = ac1.get();
                objPersons.ChargeAccount = txtChargeAccount.Text;
                objPersons.UserTypeID = long.Parse(ddlUserType.SelectedValue);


                objPersons.EmploymentStatus = long.Parse(ddlEmploymentStatus.SelectedValue);



                objPersons.OrgChartID = oc1.get();



                objPersons.PositionEmail = txtPositionEmail.Text  ;

                objPersons.OfficePhone = txtOfficePhone.Text;
                objPersons.OfficeInnerPhone = txtOfficeInnerPhone.Text;

            }



            objPersons.StatusID = 1;
            objPersons.Language = 0;

        
    }


    /// <summary>
    /// this function for clearing controls
    /// </summary>
    protected void clearAllControls()
    {
        
            txtBadge.Text = "";

            txtEmail.Text = "";
            txtFamilyName_AR.Text = "";
            txtFamilyName_EN.Text = "";

            txtInnerPhone1.Text = "";
            txtInnerPhone2.Text = "";
            txtMiddleName_AR.Text = "";
            txtMiddleName_EN.Text = "";
            txtMobile1.Text = "";
            txtMobile2.Text = "";
            txtName_AR.Text = "";
            txtName_EN.Text = "";
            txtPhone1.Text = "";
            txtPhone2.Text = "";
            strPassword = "";
            txtPassword.Text = "";
            txtRepeatPassword.Text = "";
            


            rblGender.SelectedValue = (true).ToString();

            calBirthDay.clear();


            ddlNationality.SelectedValue = "177";

            ddlPersonType.SelectedValue = "1";


            
            txtID.Text = "";

            ddlRelation.SelectedValue = "2";
            
            
            ac1.set (1);
            txtChargeAccount.Text = "";
            ddlUserType.SelectedValue = "3";


            clearGroups();

            oc1.set(-1);

            lblOrgCodeBody.Text = "N/A";

            txtPositionEmail.Text = "";

            txtOfficePhone.Text ="";
            txtOfficeInnerPhone.Text = "";


            objPersons = new Persons();

            

        
    }




    protected void Page_Load(object sender, EventArgs e)
    {


        Persons currentPerson = GlobalVars.getCurrentPerson();




        if (!Page.IsPostBack)
        {

            checkID();
            
            checkSecurityAndCustomizePage(currentPerson);


            bindGender();
            bindNationality();
            
            bindPersonType();
            bindRelation();
            bindUserType();


            bindEmploymentStatus();
            bindGroups();

            bindEducationLevel();

            checkMessages();

            BindAllControls();

            
        }
    }



   







    protected void cvBirthDayCal_ServerValidate(object source, ServerValidateEventArgs args)
    {
        if (calBirthDay.CurrentDay == "" &&  calBirthDay.CurrentMonth == "" && calBirthDay.CurrentYear ==  "")
        {
            args.IsValid = true;
            return;
        }

        try
        {
            DateTime dtNew = new DateTime( int.Parse(calBirthDay.CurrentYear), int.Parse(calBirthDay.CurrentMonth), int.Parse(calBirthDay.CurrentDay));
        }
        catch
        {
            args.IsValid = false;
            return;
        }

    }


    /// <summary>
    /// this function will bind the employment status drop down list with its data
    /// </summary>
    protected void bindEmploymentStatus()
    {
        EmploymentStatusDB objEmploymentStatusDB = new EmploymentStatusDB(ConnectionStrings.LMS);
        List<EmploymentStatus> lstEmploymentStatus = objEmploymentStatusDB.Search(new EmploymentStatus());

        ddlEmploymentStatus.DataSource = lstEmploymentStatus;
        ddlEmploymentStatus.DataTextField = "EmploymentStatusEN";
        ddlEmploymentStatus.DataValueField = "ID";
        ddlEmploymentStatus.DataBind();

    }


    /// <summary>
    /// this function for binding Person types
    /// </summary>
    protected void bindPersonType()
    {
        PersonTypeDB objPersonTypeDB = new PersonTypeDB(ConnectionStrings.LMS);
        List<PersonType> lstPersonType = objPersonTypeDB.Search(new PersonType());
        ddlPersonType.DataSource = lstPersonType;
        ddlPersonType.DataTextField = "EmployeeTypeNameEN";
        ddlPersonType.DataValueField = "ID";
        ddlPersonType.DataBind();
    }


    /// <summary>
    /// this function for binding User types
    /// </summary>
    protected void bindUserType()
    {
        UserTypeDB objUserTypeDB = new UserTypeDB(ConnectionStrings.LMS);
        List<UserType> lstUserType = objUserTypeDB.Search(new UserType());

        Persons currentPerson = GlobalVars.getCurrentPerson();

        if (currentPerson.UserTypeID == 2)
        {
            List<UserType> lstNewUserType = new List<UserType>((from objUserTypes in lstUserType where objUserTypes.ID != 1 select objUserTypes  ));
            lstUserType = lstNewUserType;

        }


        ddlUserType.DataSource = lstUserType;
        ddlUserType.DataTextField =  "TypeNameEN";
        ddlUserType.DataValueField = "ID";
        ddlUserType.DataBind();

        ddlUserType.SelectedValue = "3";

    }



    /// <summary>
    /// this function will bind the education level dropdownlist
    /// </summary>
    protected void bindEducationLevel()
    {
        EducationLevelsDB objEducationLevelsDB = new EducationLevelsDB(ConnectionStrings.LMS);
        List<EducationLevels> lstEducationLevels = objEducationLevelsDB.Search(new EducationLevels());

        ddlEducationLevel.DataSource = lstEducationLevels;
        ddlEducationLevel.DataTextField = "EducationLevelEN";
        ddlEducationLevel.DataValueField = "ID";
        ddlEducationLevel.DataBind();
    }
   



    /// <summary>
    /// this function for binding Countries
    /// </summary>
    protected void bindNationality()
    {
        CountryDB objCountryDB = new CountryDB(ConnectionStrings.LMS);
        List<Country> lstCountry = objCountryDB.Search(new Country());
        ddlNationality.DataSource = lstCountry;
        ddlNationality.DataTextField = "CountryNameEN";
        ddlNationality.DataValueField = "ID";
        ddlNationality.DataBind();

        ddlNationality.SelectedValue = "177";
    }



    /// <summary>
    /// this function for binding Relations
    /// </summary>
    protected void bindRelation()
    {
        RelationDB objRelationDB = new RelationDB(ConnectionStrings.LMS);
        List<Relation> lstRelation = objRelationDB.Search(new Relation());

        for (int i = 0; i < lstRelation.Count; i++)
        {
            if (lstRelation[i].ID == 1)
                lstRelation.Remove(lstRelation[i]);
        }

        ddlRelation.DataSource = lstRelation;
        ddlRelation.DataTextField = "RelationNameEN";
        ddlRelation.DataValueField = "ID";
        ddlRelation.DataBind();
    }



    /// <summary>
    /// this function for binding Gender
    /// </summary>
    protected void bindGender()
    {
        GenderValueDB objGenderValueDB = new GenderValueDB(ConnectionStrings.LMS);
        List<GenderValue> lstGenderValue = objGenderValueDB.Search(new GenderValue());
        rblGender.DataSource = lstGenderValue;
        rblGender.DataTextField = "GenderNameEN";
        rblGender.DataValueField =  "GenderID";

        rblGender.DataBind();

        rblGender.SelectedValue = (true).ToString();

    }


    /// <summary>
    /// this function will bind the groups checkbox list with its data
    /// </summary>
    protected void bindGroups()
    {
        GroupsDB objGroupsDB = new GroupsDB(ConnectionStrings.LMS);

        List<Groups> lstGroups = objGroupsDB.Search(new Groups());




        Persons currentPerson = GlobalVars.getCurrentPerson();

        if (!currentPerson.lstAllRulesIDs.Contains((long)RulesEnum.Give_Admin_Rule))
        {
            lstGroups = (from obj in lstGroups where obj.ID != 3 select obj).ToList<Groups>();
        }

        chkGroups.DataSource = lstGroups;
        chkGroups.DataTextField = "GroupNameEN";
        chkGroups.DataValueField = "ID";


       




        chkGroups.DataBind();

    }


    /// <summary>
    /// this function will get the selected item from checkboxlist and convert it to business objects
    /// </summary>
    protected void getGroupsValue()
    {
        lstNewPersonGroups = new List<PersonGroups>();

        foreach (ListItem li in chkGroups.Items)
        {
            if (li.Selected)
            {
                lstNewPersonGroups.Add(new PersonGroups(-1, long.Parse(li.Value)));

            }
        }

    }

    /// <summary>
    /// this function will set the chkboxlist checked value by persons object selected
    /// </summary>
    protected void setGroupsValue()
    {

        clearGroups();

        List<PersonGroups> lstPersonGroups = objPersons.lstPersonsGroups;

        foreach (PersonGroups pg in lstPersonGroups)
        {
            foreach (ListItem li in chkGroups.Items)
            {
                if (li.Value == pg.GroupsID.ToString())
                {
                    li.Selected = true;
                    break;
                }
            }
        }

    }

    /// <summary>
    /// this function will remove all selected from checkboxlist
    /// </summary>
    protected void clearGroups()
    {
        foreach (ListItem li in chkGroups.Items)
        {
            li.Selected = false;
        }
    }





    protected void ddlPersonType_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (ddlPersonType.SelectedValue == "3")
        {
            pnlEmployee.Visible = false;
            pnlFamily.Visible = true;
        }
        else
        {
            pnlEmployee.Visible = true;
            pnlFamily.Visible = false;
        }


        long groupID = -1;
        
        /*
         * Group Values
         * 
         * Family 1
         * 
         * Employee 4
         * 
         * Manager 5
         * 
         * 
         */
        
         


        /*
         * 
         * 
         * User type values
         * 
         * 
         * Family 3
         * 
         * Eployee 1
         * 
         * Manager 2
         */


        if (ddlPersonType.SelectedValue == "3")
        {
            groupID = 1;

        }
        else if (ddlPersonType.SelectedValue == "1")
        {
            groupID = 4;
        }
        else
        {
            groupID = 5;
        }



        foreach (ListItem li in chkGroups.Items)
        {
            if (li.Value == "1")
                li.Selected = false;
            if (li.Value == "4")
                li.Selected = false;
            if (li.Value == "5")
                li.Selected = false;
        }

        foreach (ListItem li in chkGroups.Items)
        {
            if (li.Value == groupID.ToString())
                li.Selected = true;
            
        }

        


    }


    /// <summary>
    /// this function will Save the Employee or Person
    /// </summary>
    protected void Save()
    {
        if (checkForRepeats())
        {
            PersonsDB objPersonsDB = new PersonsDB(ConnectionStrings.LMS);


            if (objPersons.GenID == -1)
            {
                objPersonsDB.Insert(objPersons);
                saveGroupsToDB();
                clearAllControls();
                lblResult.Text = "Data saved ok.";
            }
            else
            {
                objPersonsDB.Update(objPersons);
                saveGroupsToDB();
                BindAllControls();
                lblResult.Text = "Data saved ok.";
            }


            

            

        }
        

    }


    /// <summary>
    /// this function will save its user group data.
    /// </summary>
    protected void saveGroupsToDB()
    {
        //Saving Groups
        try
        {

            foreach (PersonGroups pg in objPersons.lstPersonsGroups)
            {
                PersonGroupsDB pgdb = new PersonGroupsDB(ConnectionStrings.LMS);
                pgdb.Delete(pg);

            }


            foreach (PersonGroups pg in lstNewPersonGroups)
            {
                pg.PersonsID = objPersons.GenID;
                PersonGroupsDB pgdb = new PersonGroupsDB(ConnectionStrings.LMS);

                pgdb.Insert(pg);
            }
        }
        catch
        {
        }

        objPersons.clearchilds();
    }



    /// <summary>
    /// this function will check if the Employee exist with the same badge or the family member exist with the ID
    /// </summary>
    /// <returns>true if ok , false for error (Employee exist before)</returns>
    protected bool checkForRepeats()
    {
        PersonsDB objPersonsDB = new PersonsDB(ConnectionStrings.LMS);


        if (objPersons.PersonTypeID == 3)
        {
            List<Persons> lstOldPersons = objPersonsDB.getPersonsByID(objPersons.ID);
            if (lstOldPersons.Count > 0)
            {
                if (objPersons.GenID == -1)
                {
                    errorExist(false);
                    return false;
                }
                else
                {
                    if (objPersons.GenID != lstOldPersons[0].GenID)
                    {
                        errorExist(false);
                        return false;
                    }
                }
            }


            lstOldPersons = objPersonsDB.getPersonsByBadge(objPersons.Badge);
            if (lstOldPersons.Count == 0)
            {
                lblError.Text = "Error , you must enter a valid badge";
                return false;
            }


        }
        else
        {
            List<Persons> lstOldPersons = objPersonsDB.getPersonsByBadge(objPersons.Badge);
            if (lstOldPersons.Count > 0)
            {
                if (objPersons.GenID == -1)
                {
                    errorExist(true);
                    return false;
                }
                else
                {
                    if (objPersons.GenID != lstOldPersons[0].GenID)
                    {
                        errorExist(true);
                        return false;
                    }
                }
            }
        }

        return true;

    }


    /// <summary>
    /// this function will show a message with the error for existense
    /// </summary>
    private void errorExist(bool bValue)
    {
        if (bValue)
        {
            lblError.Text = "Error , the badge is already found , choose a new badge";
        }
        else
        {
            lblError.Text = "Error , the id is already found , choose a new id";

        }
    }







    protected void btnSave_Click(object sender, EventArgs e)
    {
        //security check
        Persons currentPerson = GlobalVars.getCurrentPerson();
        if (!currentPerson.lstAllRulesIDs.Contains((long)RulesEnum.Editing_Acounts_page))
            return;


        if (Page.IsValid)
        {
            if ((txtRepeatPassword.Text.Trim() == "" || txtPassword.Text.Trim() == "") && txtPassword.Text.Trim() != txtRepeatPassword.Text.Trim())
            {
                lblError.Text = "Passwords didn't matched.";
                return;
            }

            ReadAllControls();

            if (objPersons.GenID == -1 && objPersons.Password == "")
            {
                lblError.Text = "Error , you must enter a password";
                return;
            }

            if (objPersons.PersonTypeID == 3)
            {
                if (objPersons.ID == "")
                {
                    lblError.Text = "Error , you must enter an ID";
                    return;
                }



            }


            Save();


        }
    }

    protected void btnDelete_Click(object sender, EventArgs e)
    {
        //security check
        Persons currentPerson = GlobalVars.getCurrentPerson();
        if (!currentPerson.lstAllRulesIDs.Contains((long)RulesEnum.Editing_Acounts_page))
            return;


        ReadAllControls();

        if (objPersons.GenID == -1)
        {
            lblError.Text = "No user account to delete";


        }


        PersonsDB objPersonsDB = new PersonsDB(ConnectionStrings.LMS);
        
        


        bool bRet = objPersonsDB.deleteAll(objPersons);


        if (bRet)
        {
            lblResult.Text = "Deleting account ok.";
            clearAllControls();
        }
        else
        {
            lblError.Text = "Deleting account error.";
        }





    }
}
